FROM ${BASE_IMAGE}

WORKDIR ${WORKDIR}

# communicate prodcut
ENV PRODUCT=${PRODUCT}
ENV PLUGINS=${PLUGINS}

# opsbot default config
ENV ID=${ID}
ENV HOST=${HOST}
ENV PORT=${PORT}
ENV API_ROOT=${API_ROOT}
ENV RTX_NAME=${RTX_NAME}
ENV NICKNAME=${NICKNAME}
ENV SESSION_RESERVED_CMD=${SESSION_RESERVED_CMD}

# plugin default settings
ENV DEFAULT_HELPER=${DEFAULT_HELPER}
ENV DEFAULT_EXTRA_TOOL=${DEFAULT_EXTRA_TOOL}
ENV DEFAULT_INTENT_CATEGORY=${DEFAULT_INTENT_CATEGORY}
ENV DEFAULT_GUIDE_URL=${DEFAULT_GUIDE_URL}

# component config
ENV BK_ENV=${BK_ENV}
ENV BK_APP_ID=${BK_APP_ID}
ENV BK_APP_SECRET=${BK_APP_SECRET}
ENV BK_GET_TOKEN_URL=${BK_GET_TOKEN_URL}
ENV BK_REFRESH_TOKEN_URL=${BK_REFRESH_TOKEN_URL}
ENV BK_PAAS_DOMAIN=${BK_PAAS_DOMAIN}
ENV BK_CHAT_DOMAIN=${BK_CHAT_DOMAIN}
ENV BK_JOB_DOMAIN=${BK_JOB_DOMAIN}
ENV BK_SOPS_DOMAIN=${BK_SOPS_DOMAIN}
ENV BK_DEVOPS_DOMAIN=${BK_DEVOPS_DOMAIN}
ENV BK_ITSM_DOMAIN=${BK_ITSM_DOMAIN}
ENV BK_CC_ROOT=${BK_CC_ROOT}
ENV BK_JOB_ROOT=${BK_JOB_ROOT}
ENV BK_SOPS_ROOT=${BK_SOPS_ROOT}
ENV BK_DEVOPS_ROOT=${BK_DEVOPS_ROOT}
ENV BK_BASE_ROOT=${BK_BASE_ROOT}
ENV BK_ITSM_ROOT=${BK_ITSM_ROOT}
ENV BACKEND_ROOT=${BACKEND_ROOT}
ENV PLUGIN_ROOT=${PLUGIN_ROOT}
ENV BK_DATA_TOKEN=${BK_DATA_TOKEN}
ENV PLUGIN_TOKEN=${PLUGIN_TOKEN}
ENV BK_SUPER_USERNAME=${BK_SUPER_USERNAME}
ENV DATA_AES_KEY=${DATA_AES_KEY}
ENV DATA_AES_IV=${DATA_AES_IV}
ENV REDIS_DB_PASSWORD=${REDIS_DB_PASSWORD}
ENV REDIS_DB_PORT=${REDIS_DB_PORT}
ENV REDIS_DB_NAME=${REDIS_DB_NAME}
ENV ES_DB_DOMAIN=${ES_DB_DOMAIN}
ENV ES_DB_PORT=${ES_DB_PORT}
ENV ES_DB_USERNAME=${ES_DB_USERNAME}
ENV ES_DB_PASSWORD=${ES_DB_PASSWORD}
ENV ORM_URL=${ORM_URL}

# protocol(xwork) config
ENV CORPID=${CORPID}
ENV FWID=${FWID}
ENV SERVICE_ID=${SERVICE_ID}
ENV SECRET=${SECRET}
ENV TOKEN=${TOKEN}
ENV AES_KEY=${AES_KEY}

# protocol(slack) config
ENV OAUTH_TOKEN=${OAUTH_TOKEN}
ENV SIGNING_SECRET=${SIGNING_SECRET}
ENV VERIFICATION_TOKEN=${VERIFICATION_TOKEN}

# protocol(qq) config
ENV APP_ID=${APP_ID}
ENV APP_KEY=${APP_KEY}
ENV QQ=${QQ}

COPY requirements.txt ./

RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.tencent.com/pypi/simple/ && pip install ujson msgpack -i https://mirrors.tencent.com/pypi/simple/

COPY . .

RUN rm -f /etc/localtime \
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone

ENTRYPOINT ["python", "src/backend/server.py"]